<?php
/**
 *
 * @category   JND
 * @package    Jnd_View
 * @subpackage Helper
 * @copyright  Copyright (c) 2005-2009 DDB
 * @version    $Id: FormSubmitJnd.php 16541 2009-10-12 17:02:30Z tbrouard $
 */
/**
 * Abstract class for extension
 */
require_once 'Zend/View/Helper/FormElement.php';
/**
 * Helper to generate a "hidden" element
 *
 * @category   JND
 * @package    Jnd_View
 * @subpackage Helper
 */
class Jnd_View_Helper_FormSubmitJnd extends Zend_View_Helper_FormElement
{

    /**
     * Generates a 'submit' element.
     *
     * @access public
     *
     * @param string|array $name If a string, the element name.  If an
     * array, all other parameters are ignored, and the array elements
     * are extracted in place of added parameters.
     * @param mixed $value The element value.
     * @param array $attribs Attributes for the element tag.
     * @return string The element XHTML. div tag + input hidden tag
     */
    public function formSubmitJnd($name, $value = null, array $attribs = null)
    {
        $info = $this->_getInfo($name, $value, $attribs);
        extract($info); // name, value, attribs, options, listsep, disable
        if (isset($id)) {
            if (isset($attribs) && is_array($attribs)) {
                $attribs['id'] = $id;
            } else {
                $attribs = array('id' => $id);
            }
        } else {
            $attribs['id'] = $name;
        }
        $attribs['name'] = $name;
        $view = Jnd_App::getResource('view');
        if (isset($attribs['src']) && $attribs['src'] != "") {
            $src = $attribs['src'];
            $helper = new Zend_View_Helper_FormImage();
            $helper->setView($view);
            return $helper->formImage($name, $src, $attribs);
        } else {
            $helper = new Zend_View_Helper_FormSubmit();
            $helper->setView($view);
            return $helper->formSubmit($name, $value, $attribs);
        }
    }
}
